package com.woniu.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.woniu.domain.Studio;
import com.woniu.service.IStudioService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 场馆模块Controller
 * 
 * @author QAQ
 * @date 2023-02-16
 */
@RestController
@RequestMapping("/studio")
public class StudioController extends BaseController
{
    @Autowired
    private IStudioService studioService;

    /**
     * 查询场馆模块列表
     */
    @RequiresPermissions("studio:studio:list")
    @GetMapping("/list")
    public TableDataInfo list(Studio studio)
    {
        startPage();
        List<Studio> list = studioService.selectStudioList(studio);
        return getDataTable(list);
    }

    /**
     * 导出场馆模块列表
     */
    @RequiresPermissions("studio:studio:export")
    @Log(title = "场馆模块", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Studio studio)
    {
        List<Studio> list = studioService.selectStudioList(studio);
        ExcelUtil<Studio> util = new ExcelUtil<Studio>(Studio.class);
        util.exportExcel(response, list, "场馆模块数据");
    }

    /**
     * 获取场馆模块详细信息
     */
    @RequiresPermissions("studio:studio:query")
    @GetMapping(value = "/{studioId}")
    public AjaxResult getInfo(@PathVariable("studioId") Long studioId)
    {
        return success(studioService.selectStudioByStudioId(studioId));
    }

    /**
     * 新增场馆模块
     */
    @RequiresPermissions("studio:studio:add")
    @Log(title = "场馆模块", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Studio studio)
    {
        return toAjax(studioService.insertStudio(studio));
    }

    /**
     * 修改场馆模块
     */
    @RequiresPermissions("studio:studio:edit")
    @Log(title = "场馆模块", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Studio studio)
    {
        return toAjax(studioService.updateStudio(studio));
    }

    /**
     * 删除场馆模块
     */
    @RequiresPermissions("studio:studio:remove")
    @Log(title = "场馆模块", businessType = BusinessType.DELETE)
	@DeleteMapping("/{studioIds}")
    public AjaxResult remove(@PathVariable Long[] studioIds)
    {
        return toAjax(studioService.deleteStudioByStudioIds(studioIds));
    }
}
